﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Usuarios.aspx.cs" Inherits="entgp.Usuarios.Usuarios" %>

<%--<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>--%>
<%@ Register Src="wucUsuarios.ascx" TagName="wucUsuarios" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .add16
        {
            background-image: url(../resources/images/chkUser.gif) !important;
        }
    </style>
</head>
<body>
    <%-- <form id="form1" runat="server">--%>
    <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="UsuariosAjax"/>
    <script type="text/javascript">
        function prepareCommand(grid, command, record, row) {
            // tramite ejecucion terminado detenido

            if (record.data.Estado == 'ACTIVO' ){
                command.text = 'Inactivar';
                command.iconCls = 'icon-statusoffline'; 
            }
            else
            {
                command.text = 'Activar';
                command.iconCls = 'icon-statusonline';          
            }
        }
    </script>
    <ext:Store runat="server" ID="sEmpresas">
        <Reader>
            <ext:JsonReader IDProperty="Key">
                <Fields>
                    <ext:RecordField Name="Value"/>
                    <ext:RecordField Name="Key"/>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store runat="server" ID="StoreUsuario" OnRefreshData="StoreRefresh" AutoLoad="false">
        <Reader>
            <ext:JsonReader IDProperty="Id">
                <Fields>
                    <ext:RecordField Name="Id" />
                    <ext:RecordField Name="Nombre" />
                    <ext:RecordField Name="Apellido" />
                    <ext:RecordField Name="Usuario" />
                    <ext:RecordField Name="Rol" />
                    <ext:RecordField Name="Email" />
                    <ext:RecordField Name="Telefono" />
                    <ext:RecordField Name="Estado" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <Proxy>
            <ext:PageProxy></ext:PageProxy>
        </Proxy>
        <BaseParams>
			<ext:Parameter Name="cbxRol_bprm" Value="#{cbxRol}.getValue()"   Mode="Raw" />
            <ext:Parameter Name="txtNombreUsuario_bprm" Value="#{txtNombreUsuario}.getValue()"   Mode="Raw" />	
        </BaseParams>
   </ext:Store>
    <ext:Store runat="server" ID="StoreRol">
        <Reader>
            <ext:JsonReader IDProperty="Key">
                <Fields>
                    <ext:RecordField Name="Key"/>
                    <ext:RecordField Name="Value"/>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Panel ID="Panel1" BodyStyle="padding:10px;background-color:#E7E4DD;" runat="server">
        <Items>
            <ext:Panel ID="Panel2" runat="server" BodyStyle="background-color:Transparent;" ButtonAlign="Center"
                Layout="Column" Height="90">
                <Items>
                    <ext:Panel ID="Panel3" runat="server" Border="false" Header="false" BodyStyle="padding:10px;background-color:Transparent;"
                        ColumnWidth=".5" Layout="Form">
                        <Items>
                            <ext:ComboBox Editable="false" FieldLabel="Rol" ID="cbxRol" StoreID="StoreRol" runat="server"
                                DisplayField="Value" ValueField="Key" TypeAhead="true" ForceSelection="true"
                                TriggerAction="All" Grow="true" AnchorHorizontal="95%" GrowMax="300" EmptyText="Todos"
                                SelectOnFocus="true" AutoDataBind="True">
                                <Triggers>
                                    <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                </Triggers>
                                <Listeners>
                                    <Select Handler="this.triggers[0].show();" />
                                    <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                    <TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />
                                </Listeners>
                            </ext:ComboBox>
                        </Items>
                    </ext:Panel>
                    <ext:Panel ID="Panel4" runat="server" Border="false" BodyStyle="padding:10px;background-color:Transparent;"
                        ColumnWidth=".5" Layout="Form">
                        <Items>
                            <ext:TextField FieldLabel="Nombre" ID="txtNombreUsuario" runat="server" AnchorHorizontal="95%" />
                            <ext:TextField FieldLabel="Nombre" ID="TextField1" runat="server" AnchorHorizontal="95%" Hidden="true" Icon="StatusOnline" />
                            <ext:TextField FieldLabel="Nombre" ID="TextField2" runat="server" AnchorHorizontal="95%" Hidden="true" Icon="StatusOffline" />
                        </Items>
                    </ext:Panel>
                </Items>
                <Buttons>
                    <ext:Button runat="server" ID="btnBuscar" Text="Buscar" Icon="Find">
                         <%--
                        <DirectEvents>
                            <Click OnEvent="btnBuscar_Click">
                                <EventMask ShowMask="true" />
                            </Click>
                        </DirectEvents>
                         --%>
                        <Listeners>
                          <Click Handler="#{StoreUsuario}.load();" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:Panel>
        </Items>
    </ext:Panel>
    <ext:GridPanel ID="GridPanelUsuarios" runat="server" StoreID="StoreUsuario" StripeRows="true"
        AutoWidth="true" AutoHeight="true" Title="Listado de Usuarios">
        <TopBar>
            <ext:Toolbar runat="server">
                <Items>
                    <ext:Button runat="server" ID="btnNuevo" Text="Nuevo" Icon="Add">
                        <DirectEvents>
                            <Click OnEvent="btnNuevo_Click">
                                <ExtraParams>
                                    <ext:Parameter Name="Operacion" Value="Nuevo" Mode="Value"/>
                                </ExtraParams>
                                <EventMask ShowMask="true" />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                    <ext:Label ID="lblNewSeeK" runat="server" Icon="ArrowRefresh" />
                    <ext:ComboBox ID="cbxChoseeEmp" runat="server" FieldLabel="Empresas" AllowBlank="false"
                        StoreID="sEmpresas" DisplayField="Value" ValueField="Key" Editable="false">
                    </ext:ComboBox>
                    <ext:Button runat="server" ID="btnNuevaBusqueda" Text="Aceptar" >
                        <DirectEvents>
                            <Click OnEvent="btnNewSeeK_Click">
                            <ExtraParams>
                                    <ext:Parameter Name="IdEmp" Value="#{cbxChoseeEmp}.getValue()" Mode="Raw"/>
                                    <ext:Parameter Name="Emp" Value="#{cbxChoseeEmp}.getValue()" Mode="Raw"/>
                                </ExtraParams>
                                <EventMask ShowMask="true" />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                </Items>
            </ext:Toolbar>
        </TopBar>
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                 <ext:CommandColumn  Width="80">
                    <Commands>
                        <ext:GridCommand CommandName="Editar"  Icon="ApplicationEdit" ToolTip-Text="Editar datos del usuario"/>
                    </Commands>
                </ext:CommandColumn>
                <ext:ImageCommandColumn>
                    <Commands>
                         <ext:ImageCommand CommandName="Activar" Text="Activar / Inactivar" ToolTip-Text="Activar / Inactivar al usuario"
                         Icon="StatusOnline" ></ext:ImageCommand>
                    </Commands>
                    <PrepareCommand Fn="prepareCommand" />
                </ext:ImageCommandColumn>
                <ext:Column ColumnID="Nombre" Header="Nombre" Width="180" Sortable="true" DataIndex="Nombre" />
                <ext:Column Header="Apellido" Width="180" Sortable="true" DataIndex="Apellido" />
                <ext:Column Header="Usuario" Width="120" Sortable="true" DataIndex="Usuario" />
                <ext:Column DataIndex="Rol" Header="Rol" Width="140" />
                <ext:Column Header="Telefono" Width="100" Sortable="true" DataIndex="Telefono" />
                <ext:Column Header="Email" Width="100" Sortable="true" DataIndex="Email" />
                <ext:Column Header="Estado" Width="100" Sortable="true" DataIndex="Estado" ColumnID="Estado" />
               
            </Columns>
        </ColumnModel>
        <DirectEvents>
            <Command OnEvent="command_Click">
                <ExtraParams>
                    <ext:Parameter Name="Id" Value="record.data.Id" Mode="Raw" />
                    <ext:Parameter Name="Estado" Value="record.data.Estado" Mode="Raw" />
                    <ext:Parameter Name="Usuario" Value="record.data.Usuario" Mode="Raw" />
                    <ext:Parameter Name="Operacion" Value="command" Mode="Raw" Encode="False" />
                </ExtraParams>
            </Command>
        </DirectEvents>
        <SelectionModel>
            <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true"/>
        </SelectionModel>
        <Listeners>
        </Listeners>
    </ext:GridPanel>
    <uc1:wucUsuarios runat="server" ID="wucUsuarios1" />
    <ext:Window ID="wSelectEmpresa" runat="server" Icon="Application" Title="Escojer Empresa"
        Modal="True" AutoHeight="true" CenterOnLoad="true" Hidden="true" ButtonAlign="Center"
        Width="300" Height="150">
        <Items>
            <ext:Panel ID="Panel5" runat="server" Border="false" Header="false" BodyStyle="padding:15px;background-color:Transparent;" Layout="Form">
                <Items>
                    <ext:ComboBox ID="cbxEmpresas" runat="server" FieldLabel="Empresas" AllowBlank="false"
                        AnchorHorizontal="100%" StoreID="sEmpresas" DisplayField="Value" ValueField="Key"
                        Editable="false"/>
                </Items>
            </ext:Panel>
        </Items>
        <Buttons>
            <ext:Button runat="server" ID="Button1" Text="Aceptar" Icon="Add">
                <DirectEvents>
                    <Click OnEvent="btnSelecionar_Click">
                    <ExtraParams>
                    <ext:Parameter Name="IdEmp" Value="#{cbxEmpresas}.getValue()" Mode="Raw"/>
                    <ext:Parameter Name="Emp" Value="#{cbxEmpresas}.getValue()" Mode="Raw"/>
                    </ExtraParams>
                    <EventMask ShowMask="true" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button runat="server" ID="Button2" Text="Cancelar" Icon="Stop">
                <Listeners>
                    <Click Handler="var TabPanel = window.parent.Ext.getCmp('NavegacionTabs');TabPanel.remove(TabPanel.activeTab, true);" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
   <%--</form>--%>
</body>
</html>
